package com.zgs.androidopengl.util

import android.app.Activity
import android.app.ActivityManager
import android.content.Context
import android.os.Build

object ESUtil {
    fun isSupportES2(activity: Activity): Boolean {
        val applicationContext = activity.applicationContext
        val systemService =
            applicationContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val deviceConfigurationInfo = systemService.deviceConfigurationInfo
        return deviceConfigurationInfo.reqGlEsVersion >= 0x20000
                || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
                && (Build.FINGERPRINT.startsWith("generic")
                || Build.FINGERPRINT.startsWith("unknown")
                || Build.MODEL.contains("google_sdk")
                || Build.MODEL.contains("Emulator")
                || Build.MODEL.contains("Android SDK built for x86")))
    }
}
